package zlx.springcloud.service.impl;


import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;
import zlx.springcloud.service.MyMessageProvider;

import javax.annotation.Resource;
import java.util.UUID;

@EnableBinding(Source.class) //定义消息推送管道
public class MyMessageProviderImpl implements MyMessageProvider {

    @Resource
    private MessageChannel output; //消息发送通道

    @Override
    public String send() {
        String serial = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(serial).build());
        return serial;
    }
}
